# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=live-media
pkgver=2020.04.24
pkgrel=0
pkgdesc="A set of C++ libraries for multimedia streaming"
url="http://live555.com/liveMedia"
arch="all"
license="LGPL-3.0-or-later"
makedepends="openssl-dev"
subpackages="$pkgname-dev $pkgname-utils"
options="!check"
source="http://dev.alpinelinux.org/archive/livemedia/live.$pkgver.tar.gz
	0001-Add-a-pkg-config-file-for-the-shared-libraries.patch
	0003-Link-shared-libraries-with-g-instead-of-gcc-to-fix-b.patch
"
builddir="$srcdir"/live

prepare() {
	chmod -R 775 *
	default_prepare
}

build() {
	./genMakefiles linux-with-shared-libraries
	make PREFIX=/usr LIBDIR=/usr/lib
}

package() {
	local testprog f so
	mkdir -p "$pkgdir"/usr/lib
	for f in BasicUsageEnvironment UsageEnvironment liveMedia groupsock; do
		mkdir -p "$pkgdir"/usr/include/$f
		cp $f/include/*.h* "$pkgdir"/usr/include/$f
		for so in $f/lib*.so.*; do
			soname=$(scanelf -B --format "#F%S" $so)
			cp $so "$pkgdir"/usr/lib/
			so=${so##*/}
			ln -s $so "$pkgdir"/usr/lib/$soname
			ln -s $so "$pkgdir"/usr/lib/${soname%.so.*}.so
		done
	done

	mkdir -p "$pkgdir"/usr/bin
	for testprog in $(find testProgs -type f -perm 755); do
		install $testprog "$pkgdir"/usr/bin
	done
}

utils() {
	pkgdesc="multimedia RTSP streaming tools"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

sha512sums="6a722b90a6ec2fc20432277be51f03c8aa7e40607c857bd527823ca0a1833bdb687ad0ad9939f0300fbfd2634360833264c7cfa8a30600f1a34c1a062d5710f3  live.2020.04.24.tar.gz
d542668dfe9386dc31389db6dfe9ed20a8395ede5d1dabfee40f49ad0db67d0b3665c8dcd59d48e4761ba00beeecc3197b2d25cb3a04ef40988f949269e7c9ef  0001-Add-a-pkg-config-file-for-the-shared-libraries.patch
5cf4a6159531e126bee83f981bd8583a1cef68cde2129f0d255b2f2d73055a21b7bf2bbcc822aa0265f1df7c32add6b95c57f59c5e08060750567fc268643612  0003-Link-shared-libraries-with-g-instead-of-gcc-to-fix-b.patch"
